package com.googlecode.gingerman.world;

import ui.Scene;

import com.googlecode.gingerman.robot.AIChassis;
import com.googlecode.gingerman.robot.AILocator;
import com.googlecode.gingerman.robot.AIRobot;
import com.googlecode.gingerman.robot.AIWeapon;
import com.googlecode.gingerman.robot.Chassis;
import com.googlecode.gingerman.robot.Health;
import com.googlecode.gingerman.robot.Locator;
import com.googlecode.gingerman.robot.Radio;
import com.googlecode.gingerman.robot.Robot;
import com.googlecode.gingerman.robot.SimpleAI;
import com.googlecode.gingerman.robot.Weapon;

public class Map2 {
	double x=0, y=0, angle=0;
	
	public Map2(Scene poligon, World world, double radius, double wallWidth, double wallHeigth){
		for (int i = 0; i < 3; i++) {
			switch(i){
			case 0: {
				x=15; y=320;
				for (int j=0; j<6; j++, x+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				x=370;
				for (int j=0; j<11; j++, x+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				x=859;
				for (int j=0; j<6; j++, x+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				break;
			}
			case 1: {
				x=281; y=15;
				for (int j=0; j<8; j++, y+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				y=415;
				for (int j=0; j<8; j++, y+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				break;
			}
			case 2: {
				x=743; y=15;
				for (int j=0; j<8; j++, y+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				y=415;
				for (int j=0; j<8; j++, y+=30){
					Wall wall=new Wall(x, y, wallWidth, wallHeigth, 0);
					
					world.addWall(wall);
					poligon.addObject(wall);
					poligon.repaint();
					
				}
				break;
			}
			default: break;
			}
		}
		
		Radio radio1 = new Radio(1);
		for (int i = 0, idCmd = 0; i < 3; i++) {
			
			switch(i){
			case 0: {x=50; y=50; angle=Math.PI/4; break;}
			case 1: {x=974; y=50; angle=3*Math.PI/4; break;}
			case 2: {x=512; y=590; angle=-Math.PI/2; break;}
			default: break;
			}
			
			Robot robot = new Robot(5, idCmd, world);
			Locator locator = new Locator(robot);
			Chassis chassis = new Chassis(x, y, angle, radius, robot);
			Weapon weapon = new Weapon(robot);
			SimpleAI AI = new SimpleAI((AIRobot)robot, (AIChassis)chassis, (AILocator)locator, (AIWeapon)weapon,radio1);
			Health health=new Health(robot);
			
			robot.setChassis(chassis);
			robot.setLocator(locator);
			robot.setWeapon(weapon);
			robot.setSimpleAI(AI);
			robot.setGhealth(health);
			
			world.addRobot(robot);
			poligon.addObject(health);
			poligon.addObject(robot);
			poligon.repaint();
		
		}
		
		Radio radio2 = new Radio(2);
		for (int i = 0, idCmd = 1; i < 3; i ++) {
			
			switch(i){
			case 0: {x=50; y=590; angle=-Math.PI/4; break;}
			case 1: {x=974; y=590; angle=-3*Math.PI/4; break;}
			case 2: {x=512; y=50; angle=Math.PI/2; break;}
			default: break;
			}
			
			Robot robot = new Robot(5, idCmd, world);
			Locator locator = new Locator(robot);
			Chassis chassis = new Chassis(x, y, angle, radius, robot);
			Weapon weapon = new Weapon(robot);
			SimpleAI AI = new SimpleAI((AIRobot)robot, (AIChassis)chassis, (AILocator)locator, (AIWeapon)weapon,radio2);
			Health health=new Health(robot);
			
			robot.setChassis(chassis);
			robot.setLocator(locator);
			robot.setWeapon(weapon);
			robot.setSimpleAI(AI);
			robot.setGhealth(health);
			
			world.addRobot(robot);
			poligon.addObject(health);
			poligon.addObject(robot);
			poligon.repaint();
			
		}
	}
	
}
